from piercing.pierc_common import PiercMaxOuterParams
import math


# 不同长度L工具串的最大外径
def get_maximum_tool_outer_diameter(params: PiercMaxOuterParams) -> float:
    factor_a: float = params.curvature_radius + params.casing_inner_diameter / 1000 / 2
    factor_b: float = math.pow(params.tool_length, 2) / 4
    D: float = ( math.sqrt(
        math.pow(factor_a, 2) - factor_b) - params.curvature_radius + params.casing_inner_diameter / 1000 / 2) * 1000
    D_max: float = round(D, 2)
    return D_max



if __name__ == '__main__':
    params = PiercMaxOuterParams()
    params.curvature_radius = 30
    params.casing_inner_diameter = 120
    params.tool_length = 2.68
    D_max = get_maximum_tool_outer_diameter(params)
    print(D_max)
